/**
 * Created by Administrator on 2018/6/15.
 */
function addBid($scope, $route, CertusFormAjax, CertusJsonAjax, $location, $http, $cookies, $routeParams) {
    $scope.precedenceSelect = [
        {name: "低", precedence: 1},
        {name: "中", precedence: 2},
        {name: "高", precedence: 3}
    ]

    $scope.bid = {};
    //暂时 写死
    $scope.bid.templateCode = "TBLC";

    CertusFormAjax.ajax("projBaseInfo", {"projId": $routeParams.projId}, function (res) {
        $scope.bid.proName = res.data.proName;
        //项目 编号
        $scope.bid.proNumber = res.data.proNumber;
        //项目区域
        $scope.bid.proArea = res.data.proArea;
        $scope.bid.projId = $routeParams.projId;

        //初始化
        CertusFormAjax.ajax("departmentUser",{projId:$scope.bid.projId},function(res){
            //姓名 id
            $scope.bid.principalName = res.data.userName;
            $scope.bid.specifiedMan = res.data.userId;

        })
        //客户 名称
        $scope.bid.customName = res.data.customName;

    })
    var picker1 = $('#datetimeid').datetimepicker({
        format: 'YYYY-MM-DD',
        locale: moment.locale('zh-cn'),
        //minDate: '2016-7-1'
    }).on('dp.change', function (e) {
        var result = new moment(e.date).format('YYYY-MM-DD');
        if (result && !angular.isUndefined(result)) {
            $scope.bid.deadlineDate = result;
            $scope.$apply();
        }
    });



    $scope.submitBid = function () {
        if (certusValidateNotnull()) {
            if ($scope.bid.principalName && $scope.bid.principalName != "") {

                // var regex = /[0-9]*/g;
                if ($scope.bid.specifiedMan) {
                    CertusJsonAjax.ajax("bidCommit", $scope.bid, function (res) {
                        if (res.data.errorMsg) {
                            if (res.data.errorMsg) {
                                layer.msg(res.data.errorMsg);
                                return;
                            }
                        }
                        history.back();
                    })
                } else {
                    layer.msg("请包含正确工号");
                }
            }

        } else {
            layer.msg("请按照页面要求填写");
        }
    }


}
